package com.wechat.config;

import java.util.Set;

import com.swak.utils.Sets;
import com.wechat.Cons;
import com.wechat.annotation.Robot;

import lombok.Getter;
import lombok.experimental.Accessors;

/**
 * RobotBean.
 * 
 * @author DELL
 */
@Getter
@Accessors(chain = true)
public class RobotBean {
	private static Set<RobotBean> ROBOTS = Sets.newHashSet();

	private final String id;
	private final String name;
	private final String summary;
	private final String method;
	private final Robot robot;
	private final Object service;

	RobotBean(Robot robot, Object service) {
		this.robot = robot;
		this.service = service;
		this.id = robot.id() + Cons.ID_Robot;
		this.name = robot.name();
		this.summary = robot.summary();
		this.method = robot.method();
	}

	public static RobotBean New(Robot robot, Object service) {
		RobotBean bean = new RobotBean(robot, service);
		ROBOTS.add(bean);
		return bean;
	}

	public static Set<RobotBean> robots() {
		return ROBOTS;
	}
}
